package services

import (
	"lottery/dao"
	"lottery/datasource"
	"lottery/models"
)

type EventService interface {
	Get(id int) (has bool, data *models.TbEvent)
	GetAll() []models.TbEvent
	GetByUser(userId int) []models.TbEvent
	Update(data *models.TbEvent, columns []string) error
	Create(data *models.TbEvent) error
}

type eventService struct {
	dao *dao.EventDao
}

func NewEventService() EventService {
	return &eventService{dao: dao.NewEventDao(datasource.InstanceDbMaster())}
}

func (s *eventService) Get(id int) (has bool, data *models.TbEvent) {
	return s.dao.Get(id)
}

func (s *eventService) GetAll() []models.TbEvent {
	return s.dao.GetAll()
}

func (s *eventService) GetByUser(userId int) []models.TbEvent {
	return s.dao.GetByUser(userId)
}

func (s *eventService) Update(data *models.TbEvent, columns []string) error {
	return s.dao.Update(data, columns)
}

func (s *eventService) Create(data *models.TbEvent) error {
	return s.dao.Create(data)
}
